package com.webchat.rmi.user;

import com.webchat.common.bean.APIPageResponseBean;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.domain.vo.request.AccountRelationQueryDTO;
import com.webchat.domain.vo.request.CreateAccountRequestVO;
import com.webchat.domain.vo.request.CreateRobotRequestVO;
import com.webchat.domain.vo.request.UserRegistryInfoRequestVO;
import com.webchat.domain.vo.request.ValidateAccountPasswordReqVO;
import com.webchat.domain.vo.response.UserBaseResponseInfoVO;
import com.webchat.domain.vo.response.UserBaseResponseVO;
import com.webchat.rmi.interceptor.RpcRequestInterceptor;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Author 程序员七七
 * @webSite https://www.coderutil.com
 * @Date 2025/1/14 00:51
 * @description
 */
@FeignClient(name = "webchat-user-service", contextId = "userServiceClient", configuration = RpcRequestInterceptor.class)
public interface UserServiceClient {

    /**
     * 查询用户详情
     *
     * @param userId 用户ID
     * @return
     */
    @GetMapping("/user-service/user/info/{userId}")
    APIResponseBean<UserBaseResponseInfoVO> userInfo(@PathVariable String userId);

    /**
     * 获取群聊下所有用户id
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/subscriber/{relationType}/{account}")
    APIResponseBean<Set<String>> getAllSubscriberByAccount(@PathVariable Integer relationType, @PathVariable String account);

    /**
     * 获取群聊下所有用户id
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/isSubscribe/{relationType}/{userAccount}/{account}")
    APIResponseBean<Boolean> isSubscribe(@PathVariable Integer relationType, @PathVariable String userAccount, @PathVariable String account);

    /**
     * 获取群聊下所有用户id
     *
     * @return
     */
    @PostMapping("/user-service/batchIsSubscribe")
    APIResponseBean<Map<String, Boolean>> batchIsSubscribe(@RequestBody AccountRelationQueryDTO accountRelationQuery);

    /**
     * 根据手机号查询用户基础信息
     *
     * @param mobile
     * @return
     */
    @GetMapping("/user-service/user/mobile/info/{mobile}")
    APIResponseBean<UserBaseResponseVO> userBaseInfo(@PathVariable String mobile);

    /**
     * 根据用户昵称查询用户基础信息
     *
     * @param name
     * @return
     */
    @GetMapping("/user-service/user/name/info/{name}")
    APIResponseBean<UserBaseResponseVO> userNameBaseInfo(@PathVariable String name);

    /**
     * 新账号注册
     *
     * @param request
     * @return
     */
    @PostMapping("/user-service/user/register")
    APIResponseBean<Boolean> registry(@RequestBody UserRegistryInfoRequestVO request);

    /**
     * 账号列表查询
     *
     * @param roleCode
     * @param userName
     * @param mobile
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/user-service/account/page")
    APIPageResponseBean<UserBaseResponseInfoVO> page(
            @RequestParam(value = "userId", required = false) String userId,
            @RequestParam(value = "roleCode") Integer roleCode,
            @RequestParam(value = "userName", required = false) String userName,
            @RequestParam(value = "mobile", required = false) String mobile,
            @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize);


    /**
     * 创建机器人
     *
     * @return
     */
    @PostMapping("/user-service/account/createRobot")
    APIResponseBean createRobot(@RequestBody CreateRobotRequestVO requestPram);

    /**
     * 创建公众号
     * 默认只有管理员可以创建公众号
     *
     * @return
     */
    @PostMapping("/user-service/account/createPublicAccount")
    APIResponseBean createPublicAccount(@RequestBody CreateAccountRequestVO requestPram);

    /**
     * 创建服务号
     * 默认只有管理员可以创建公众号
     *
     * @return
     */
    @PostMapping("/user-service/account/createServerAccount")
    APIResponseBean createServerAccount(@RequestBody CreateAccountRequestVO requestPram);


    /**
     * 批量查询用户详情
     * 底层走Redis
     *
     * @param userIds
     * @return
     */
    @PostMapping("/user-service/account/batchGet")
    APIResponseBean<Map<String, UserBaseResponseInfoVO>> batchGet(@RequestBody Set<String> userIds);

    /**
     * 批量查询用户详情缓存
     *
     * @param userIds
     * @return
     */
    @PostMapping("/user-service/account/batchGetList")
    APIResponseBean<List<UserBaseResponseInfoVO>> batchGet(@RequestBody List<String> userIds);

    /**
     * 账号搜索
     * 根据query参数对手机号/账号做完全匹配
     *
     * @param account
     * @return
     */
    @GetMapping("/user-service/account/query")
    APIResponseBean<UserBaseResponseInfoVO> queryAccount(@RequestParam String account);


    /**
     * 校验用户密码是否正确
     *
     * @return
     */
    @PostMapping("/user-service/account/query")
    APIResponseBean<Boolean> validateAccountPassword(@RequestBody ValidateAccountPasswordReqVO validateAccountPasswordReq);
}
